<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
        <title>InfinityJEEEU Java Code Generator</title>
        <link href="../css/default.css" rel="stylesheet" type="text/css" />
        <link href="../lib/codemirror.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="../js/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="../lib/codemirror.js"></script>
        <script type="text/javascript" src="../js/sgs.js"></script>
    </head>   
    <body onload="setGenerateSampleDemo()">
        <div id="wrapper">
        <div id="header">
    <div id="logo">
        <h1><a href="../html/index.html">无垠式Java通用代码生成器</a></h1>
        <h2><a href="../html/index.html">自2014年起为公众服务</a></h2>
    </div>
    <!-- end div#logo -->
    <!-- end div#menu -->
</div>
            <!-- end div#header -->
            <div id="page">
                <div id="content">
                    <div id="welcome">
                        <h2></h2>
                        <!-- Fetch Rows -->                        
                        <div style="float:left;font-size:12pt">生成结果:</div>
                        <div id="generateResults"></div>
                        <div style="clear:both"></div>
                        <br/><br/><br/>
                        
						<div style="float:left;font-size:12pt">SGS代码输入窗口：</div>
						<form id="codeForm" action="" method="post">
                        <textarea id="mycode" name="mycode" onchange="colorCode()">
						</textarea><br/>
						<input type="checkbox" id="ignoreWarning" name="ignoreWarning" value="true" checked="false"/>忽略编译警告
						<br/><br/>
                        <input type="button" value="生成代码" onclick="submitCode();"/><input type="reset" value="重置"/>
                        </form>     
                    </div>
                    <!-- end div#welcome -->
                </div>
                <!-- end div#content -->
                <div id="sidebar">
                    <!--ul-->
                    	<!-- Common Navigation Panel for our site -->
						<li id="submenu">
						    <h2>功能菜单</h2>
						    <ul>
						      <li><a href="../html/index.html">使用SGS生成代码</a></li>
						      <li><a href="../html/parseexcel.html">使用Excel生成代码</a></li>
							  <li><a href="../tools/multiTokenReplacer.html">无敌替换王</a></li>
							  <li><a href="../tools/sqlGenerator.html">果核里的SQL</a></li>
							  <li><a href="../tools/dataFormatGenerator.html">数据变形虫</a></li>
							  <li><a href="../tools/htmlTokenGenerator.html">HTML造砖匠</a></li>
							  <li><a href="../tools/urlEncodeParser.html">URL加密解密</a></li>
							  <li><a href="../tools/utf8EncodeParser.html">UTF8加密解密</a></li>
							  <li><a href="../tools/base64EncodeParser.html">Base64加密解密</a></li>
						    </ul>
						</li>
                    <!--/ul-->
                </div>
                <!-- end div#sidebar -->
                <div style="clear: both; height: 1px"></div>
            </div>
            <!-- Common footer for our site -->
			<div id="footer">
			    <p id="legal">作者：火鸟  电邮:jerry_shen_sjf@qq.com QQ群:277689737<br/>
			    </p>
			</div>
        </div>
        <!-- end div#wrapper -->
<script type="text/javascript">
var editor = CodeMirror.fromTextArea($("#mycode")[0],
		{	mode:"text/sgs",indentUnit:4,
			lineNumbers: true
	});
editor.setSize('50em','160em');
  
function submitCode(){
	$("#generateResults").html("");
	var ignoreWaring = $("#ignoreWarning").get(0).checked;
	$.ajax({
        type: "post",
        url: "../facade/generateSampleCodeFacade",
        data: {code:editor.getValue(),ignoreWarning:ignoreWaring},
        dataType: 'json',
        success: function(data, textStatus) {
					debugger;
           if (data.success == true){
           		$("#generateResults").html("<strong>"+data.projectName+"</strong><a href=\"../source/"+data.projectName+".zip\">Download</a>");
           }else if (data.success == false){
        	   var resultStr = "<span style='color:red;font-size:16pt''>";
        	   for (var i = 0; i < data.compileErrors.length;i++){
        		   resultStr += data.compileErrors[i];
        		   resultStr += "<br/>"
        	 		  }   
        	   if (data.compileErrors.length > 0) resultStr += "</span>";
        	   resultStr += "<br/><span style='color:#cd740c;font-size:16pt'>";    	   		 
        	   for (var i = 0; i < data.compileWarnings.length;i++){
        		   resultStr += data.compileWarnings[i];
        		   resultStr += "<br/>"
        	 		  }
        	   if (data.compileWarnings.length > 0) resultStr += "</span>";
        	   $("#generateResults").html(resultStr);
           }
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			//alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	
}

function Write2Text(filename)
{
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	var f = fso.CreateTextFile(filename, true);
	for(var i=0;i<arr.length;i++)
	{
	f.write(arr[i])
	f.WriteBlankLines(1)
	}
	f.Close();
}

function setEmployeeDemo(){
	readText("employeetest.sgs")
}

function setMyAreasDemo(){
	readText("myareas.sgs")
}

function setMySportsDemo(){
	readText("mysports.sgs")
}

function readText(myfilename){
	$("#generateResults").html("");
	$.ajax({
        type: "get",
        url: "../facade/readSgsFileFacade",
        data: {filename:myfilename},
        dataType: 'text',
        success: function(data, textStatus) {
           //alert(data);
           if ( data != null & data!="")
           		//$("#mycode").val(data);
           		$("#mycode").text(editor.getValue(editor.setValue(data)));
           
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	 
}

function readDocs(myfilename){
	$.ajax({
        type: "post",
        url: "../facade/readDocsFileFacade",
        data: {filename:myfilename},
        dataType: 'text',
        success: function(data, textStatus) {
           //alert(data);
           if ( data != null & data!=""){
        	   $("#mycode").text(editor.getValue(editor.setValue(data)));        	   
           }           		
        },
        complete : function(XMLHttpRequest, textStatus) {
        
		},
		error : function(XMLHttpRequest,textStatus,errorThrown) {
			alert("Error:"+textStatus);
			//alert(errorThrown.toString());
		}
    });	 
}

function setGenerateSampleDemo(){
	readText("GenerateSample.sgs")
}

function setGenerateWithAuthDemo(){
	readText("GenerateWithAuth.sgs")
}

function setGenerateS2SHDemo(){
	readText("GenerateS2SH.sgs")
}

function setGenerateS2SHCDemo(){
	readText("GenerateS2SHC.sgs")
}

function setGenerateIntegerDemo(){
	readText("GenerateInteger.sgs")
}

function setGenerateInverseDemo(){
	readText("GenerateInverse.sgs")
}

function setGenerateInverseSimpleJEEDemo(){
	readText("GenerateInverseSimpleJEE.sgs")
}

function setGenerateIntegerSimpleJEEDemo(){
	readText("GenerateIntegerSimpleJEE.sgs")
}

function setGenerateAdvanceDemo(){
	readText("GenerateAdvanced.sgs")
}


function setGenerateCallMagicDemo(){
	readText("GenerateCallMagic.sgs")
}

function setGenerateCallMagicSimpleJEEDemo(){
	readText("GenerateCallMagicSimplejee.sgs")
}

function setUserSystemsDemo(){
	readText("usersystems.sgs")
}

function setMyProjectDemo(){
	readText("myproject.sgs")
}

function setReadme(){
	readDocs("Readme.txt")
}

function colorCode(){
	
}
</script>        
    </body>
</html>
